<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->systemName;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/main.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/style.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/cn.js"></script>

<!--colorbox-->
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/colorbox.jquery/jquery.colorbox.js"></script>
<link href="<?php echo $this->baseUrl;?>/files/admin/js/colorbox.jquery/colorbox2.css" rel="stylesheet" type="text/css"/>
</head>

<body>
	<div id="main">
		<div id="navigation">当前位置：<a href="<?php echo $this->projectUrl(array('action'=>'index'));?>">主协议列表</a> &gt; <a href="<?php echo $this->projectUrl(array('action'=>'main-event','mainVersion'=>$this->vars['mainVersion']));?>">[<?php echo $this->vars['mainVersion'];?>]事件列表</a> &gt;<a href="<?php echo $this->projectUrl(array('action'=>'main-event-field','mainVersion'=>$this->vars['mainVersion'],'eventId'=>$this->vars['eventId']));?>">[<?php echo $this->vars['eventId'];?>]字段列表</a>&gt;<span id="focus">编辑字段</span></div>
		<div id="body">
			<div id="edit">
				<form id="editForm" name="editForm" method="post" action="">
					<table class="table">
						<tr>
							<td colspan="2">*为必填项</td>
						</tr>
						<tr>
							<td width="20%">主协议版本号：</td>
							<td>
								<?php echo $this->row['mainVersion'];?>
								<input name="mainVersion" type="hidden"id="mainVersion" value="<?php echo $this->row['mainVersion'];?>" />
							</td>
						</tr>
						<tr>
							<td width="20%">事件Id：</td>
							<td>
								<?php echo $this->row['eventId'];?>
								<input name="eventId" type="hidden" id="eventId" value="<?php echo $this->row['eventId'];?>"/>
							</td>
						</tr>
						<tr>
							<td width="20%">字段序号：</td>
							<td>
								<input name="fieldSort" type="text" class="validate[callback[checkFieldSort,1]] input" id="fieldSort" value="<?php echo $this->row['fieldSort'];?>" size="30" style="width:300px;" /> * 
							</td>
						</tr>
						<tr>
							<td width="20%">字段名称：</td>
							<td>
								<input name="fieldName" type="text" class="validate[required] input" id="fieldName" value="<?php echo $this->row['fieldName'];?>" size="30" style="width:300px;" /> * 
							</td>
						</tr>
						<tr>
							<td width="20%">字段类型：</td>
							<td><?php echo isset($this->fieldTypeRows[$this->row['fieldType']]['nameNote']) ? $this->fieldTypeRows[$this->row['fieldType']]['nameNote'] : '';?> (<?php echo $this->row['fieldType'];?>)
								<input name="fieldType" type="hidden" id="fieldType" value="<?php echo $this->row['fieldType'];?>"/>
								<a href="javascript:void(0);" onclick="$(document).ready(function(){$.fn.colorbox({href:'<?php echo $this->projectUrl(array('controller'=>'act-md-main', 'action'=>'field-type'));?>?'+Math.random()});});">对照</a>
								
							</td>
						</tr>
						<tr>
							<td width="20%">实现方式：</td>
							<td>	
								<input name="complyMode" type="radio" class="type" value="0" <?php echo $this->row['complyMode'] == 0 ? ' checked="checked"' : '';?>/> SDK
								<input name="complyMode" type="radio" class="type" value="1" <?php echo $this->row['complyMode'] == 1 ? ' checked="checked"' : '';?>/> APP
							</td>
						</tr>
						<tr>
							<td width="20%">备注：</td>
							<td><textarea name="note" cols="30" rows="5" class="input" id="note" style="width:300px;"><?php echo $this->row['note'];?></textarea></td>
						</tr>
						<tr>
							<td width="20%">&nbsp;</td>
							<td><input type="submit" name="button" id="button" value="提交" class="button"/></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>

<script language="javascript">
function checkFieldSort(account)
{
    var url = '<?php echo $this->projectUrl(array('action'=>'get-main-pact-event-field-sort-is-exists-by-json','id'=>$this->row['id'],'mainVersion'=>$this->vars['mainVersion'],'eventId'=>$this->vars['eventId'], 'account'=>'{account}'), NULL, false);?>'+'?rand/' + Math.random();
	url = url.replace('{account}', account);
	checkResult = {'isRight':true, 'message':''};
	
	if ($.trim($("#fieldSort").val()) == '') {
		return checkResult = {'isRight':false, 'message':'字段序号。'};
	}
	if (account != '') {
		$.ajax({
			type: "GET",
			url: url,
			dataType: "json",
			async: false,
			success: function(data){
				if (data == 1) {
					checkResult = {'isRight':false, 'message':'* 事件[<?php echo $this->vars['eventId'];?>]的字段序号已存在，请换一个。'};
				}
			} 
		}); 
	}
	return checkResult;
}

$("#editForm").submit(function(){
	return true;
});
</script>
</body>
</html>